/*
 * Wire
 * Copyright (C) 2018 Wire Swiss GmbH
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see http://www.gnu.org/licenses/.
 *
 */

.with-separators {
  position: relative;
  &::before {
    position: absolute;
    top: 0;
    right: 0;
    left: var(--left-list-item-left-width);
    border-bottom: 1px solid var(--border-color);
    content: '';
  }
  &::after {
    position: absolute;
    right: 0;
    bottom: 0;
    left: var(--left-list-item-left-width);
    border-bottom: 1px solid var(--border-color);
    content: '';
  }
}

.panel {
  overflow: hidden;

  &__actions {
    padding: 0;
    margin: 0;
    list-style: none;
  }

  &__page {
    display: flex;
    height: 100%;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: overlay;

    &--move-out--left,
    &--move-out--right,
    &--move-in--left,
    &--move-in--right {
      pointer-events: none;

      & .panel__header {
        transition: opacity var(--animation-timing-fast) var(--ease-out-quart);
      }

      & .panel__content,
      & .panel__footer {
        transition: transform var(--animation-timing-fast) var(--ease-out-expo);
      }
    }

    &--move-out--left,
    &--move-in--left {
      & .panel__content,
      & .panel__footer {
        transform: translateX(var(--panel-width));
      }
    }

    &--move-out--right,
    &--move-in--right {
      & .panel__content,
      & .panel__footer {
        transform: translateX(calc(var(--panel-width) * -1));
      }
    }

    &--move-in--left,
    &--move-in--right {
      position: absolute;
      top: 0;
      width: var(--panel-width);

      & .panel__header {
        animation: var(--animation-timing-fast) var(--ease-out-expo) headerfadein;
      }
    }
    &--move-out--left,
    &--move-out--right {
      & .panel__header {
        opacity: 0;
      }
    }

    &--move-in--left {
      & .panel__content,
      & .panel__footer {
        right: var(--panel-width);
      }
    }

    &--move-in--right {
      & .panel__content,
      & .panel__footer {
        right: calc(var(--panel-width) * -1);
      }
    }
  }

  &__content {
    position: relative;
    display: flex;
    width: var(--panel-width);
    min-height: var(--panel-content-min-height);
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    transform: translateX(0);

    ul {
      padding: 0;
      margin: 0;
      list-style: none;

      li {
        position: relative;

        &:not(:last-child) {
          &::after {
            position: absolute;
            right: 0;
            bottom: 0;
            left: var(--left-list-item-left-width);
            border-bottom: 1px solid var(--border-color);
            content: '';
          }
        }
      }
    }

    &--fill {
      flex-grow: 1;
    }
  }

  &__info-text {
    > .participant-devices__link {
      display: block;
    }

    &:focus-visible {
      .focus-outline;
      .focus-offset;
      .focus-border-radius;
    }

    body.theme-dark & {
      color: var(--gray-50);
    }

    &--margin {
      margin: 0 16px;
    }

    &--margin-bottom {
      margin: 0 16px 8px;
    }

    &--head {
      display: block;
      font-weight: var(--font-weight-bold);
      text-transform: uppercase;
    }
  }

  &__item-offset {
    &:focus-visible {
      outline-offset: -0.2rem;
    }
  }

  &__action-item {
    .button-reset-default();
    min-height: 56px;
    align-items: center;
    padding: 1rem;

    &--link {
      .panel__action-item__icon {
        width: 32px;
      }
    }

    &-label {
      display: flex;
      flex-grow: 1;
      align-items: center;
      cursor: pointer;
    }

    &.custom {
      cursor: default;
    }

    &--alternate {
      position: relative;
      display: flex;
      align-items: center;

      & > div {
        position: absolute;
        display: flex;
        width: 100%;
        height: 100%;
        align-items: center;
      }
    }

    &--info {
      display: flex;
      margin-right: 24px;
      margin-left: 12px;
    }

    &__text--info {
      margin: 0;
      .subline;
    }

    &__icon--info {
      margin-top: 3px;
      margin-right: 16px;
    }

    &--alternate &__default {
      display: flex;
      align-items: center;
      opacity: 1;
      transform: translateX(0);
      transition: all var(--animation-timing-fast) var(--ease-out-expo);
    }

    &--alternate &__alternative {
      display: none;
      align-items: center;
      opacity: 0;
      transform: translateX(10px);
      transition: all var(--animation-timing-fast) var(--ease-out-expo);
    }

    &--show-alternative &__default {
      display: none;
      opacity: 0;
      transform: translateX(-10px);
    }

    &--show-alternative &__alternative {
      display: flex;
      opacity: 1;
      transform: translateX(0);
    }

    &__icon,
    &__context {
      display: flex;
      min-width: 40px;
      margin-left: 1px;

      path {
        fill: currentColor;
      }
    }

    &__context {
      width: auto;
      height: 100%;
      align-items: center;
    }

    &__text {
      display: flex;
      flex-grow: 1;
      align-items: center;
      .text-medium;
    }

    &__status {
      .subline;
      color: var(--gray-70);
      justify-self: flex-end;

      .panel__action-item__summary & {
        justify-self: flex-start;
      }

      &-title {
        margin-bottom: 4px;
        font-size: 0.875rem;
        font-weight: 500;
      }

      body.theme-dark & {
        color: var(--white);
      }
    }

    &__summary {
      overflow: hidden;
      flex-direction: column;
      flex-grow: 1;
      align-items: flex-start;
      justify-content: center;
      text-align: left;
    }

    .service-icon {
      width: 16px;
      height: 16px;
    }

    &--no-border {
      border-bottom: none;
    }
  }

  &__info-item,
  &__action-item {
    display: flex;
    width: 100%;
    padding-inline: 16px;
    svg {
      path {
        fill: currentColor;
      }
    }
  }

  &__info-item {
    .with-separators;
    padding-block: 10px;
    &__icon {
      min-width: 40px;
    }
  }

  &__header {
    display: flex;
    height: var(--content-title-bar-height);
    min-height: var(--content-title-bar-height);
    align-items: center;
    justify-content: space-between;

    & > .icon-button {
      display: flex;
      width: var(--content-title-bar-height);
      height: var(--content-title-bar-height);
      justify-content: center;
    }

    &__title {
      .ellipsis-nowrap;
      .heading-h3;

      &:focus-visible {
        .focus-outline;
        .focus-offset;
        .focus-border-radius;
      }

      &:first-child {
        flex-grow: 1;
        margin-left: var(--content-title-bar-height);
        text-align: center;
      }

      &:last-child {
        flex-grow: 1;
        margin-right: var(--content-title-bar-height);
        text-align: center;
      }
    }

    &--reverse {
      flex-direction: row-reverse;
    }
  }

  &__footer {
    position: relative;
    transform: translateX(0);

    &__info {
      margin: 2px 0;
      color: var(--background-fade-40);
      font-size: var(--font-size-small);
      font-weight: var(--font-weight-regular);
      text-align: center;
    }
  }

  &__tabs {
    display: flex;
    height: 44px;
    min-height: 44px;
    padding: 0 8px;
    border-bottom: 1px solid var(--foreground-fade-32);
    margin-bottom: 0;
  }

  &__tab {
    .flex-center;

    flex-grow: 1;
    border-bottom: 1px solid transparent;
    margin-bottom: -1px;
    color: var(--background);
    cursor: pointer;
    font-size: var(--font-size-medium);
    font-weight: var(--font-weight-semibold);
    opacity: 0.56;

    &--active {
      border-bottom-color: var(--background-fade-32);
      cursor: default;
      opacity: 1;
    }

    &:first-child {
      margin-left: 8px;
    }

    &:last-child {
      margin-right: 8px;
    }
  }
}

button.panel__action-item,
.panel__action-button {
  .button-states();
  .text-medium;

  &:disabled {
    cursor: not-allowed;
  }
}

button.panel__action-item:focus-visible {
  .focus-outline;
  outline-offset: -0.2rem;
  .focus-border-radius;
}

@keyframes headerfadein {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

.notification-section {
  padding: 0 1rem;
  border: none;
  margin-top: 1.5rem;
}
